package com.ruoyi.tmsdriveracc.service.impl;

import com.ruoyi.tmsdriveracc.domain.AErrorImages;
import com.ruoyi.tmsdriveracc.mapper.AErrorImagesDao;
import com.ruoyi.tmsdriveracc.service.AErrorImagesService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * (AErrorImages)表服务实现类
 *
 * @author 小何
 * @since 2022-04-24 00:13:03
 */
@Service("aErrorImagesService")
public class AErrorImagesServiceImpl implements AErrorImagesService {
    @Resource
    private AErrorImagesDao aErrorImagesDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public AErrorImages queryById(Integer id) {
        return this.aErrorImagesDao.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param aErrorImages 筛选条件
     * @param pageRequest  分页对象
     * @return 查询结果
     */
    @Override
    public Page<AErrorImages> queryByPage(AErrorImages aErrorImages, PageRequest pageRequest) {
        long total = this.aErrorImagesDao.count(aErrorImages);
        return new PageImpl<>(this.aErrorImagesDao.queryAllByLimit(aErrorImages, pageRequest), pageRequest, total);
    }

    /**
     * 新增数据
     *
     * @param aErrorImages 实例对象
     * @return 实例对象
     */
    @Override
    public AErrorImages insert(AErrorImages aErrorImages) {
        this.aErrorImagesDao.insert(aErrorImages);
        return aErrorImages;
    }

    /**
     * 修改数据
     *
     * @param aErrorImages 实例对象
     * @return 实例对象
     */
    @Override
    public AErrorImages update(AErrorImages aErrorImages) {
        this.aErrorImagesDao.update(aErrorImages);
        return this.queryById(aErrorImages.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.aErrorImagesDao.deleteById(id) > 0;
    }
}
